﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 人事工资管理系统
{
    public partial class frmUserCheckChange : Form
    {
        public frmUserCheckChange()
        {
            InitializeComponent();
        }
        PMSClass.DBOperate operate = new PMSClass.DBOperate();
        SqlConnection conn = PMSClass.DBConnection.MyConnection();
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = "select * from tb_check where PID='" + comboBox1.Text + "'";
            DataSet ds = operate.GetTable(str);
            ds.Dispose();
            textBox2.Text = ds.Tables[0].Rows[0][2].ToString();
            textBox3.Text = ds.Tables[0].Rows[0][3].ToString();
            textBox4.Text = ds.Tables[0].Rows[0][4].ToString();
            textBox5.Text = ds.Tables[0].Rows[0][5].ToString();
            textBox6.Text = ds.Tables[0].Rows[0][6].ToString();
            textBox7.Text = ds.Tables[0].Rows[0][7].ToString();
            textBox8.Text = ds.Tables[0].Rows[0][8].ToString();
        
        }

        private void frmUserCheckChange_Load(object sender, EventArgs e)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from tb_check", conn);
            SqlDataReader sdr = cmd.ExecuteReader();
            while (sdr.Read())
            {
                comboBox1.Items.Add(sdr["PID"].ToString());
            }
            sdr.Close();
            conn.Close();
        }

        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            string id = comboBox1.SelectedItem.ToString();
            string strUpdateSql = "update tb_check set PID='" + comboBox1.Text + "',Pname='" + textBox2.Text + "',Pdep='" + textBox3.Text + "',PKpcontent='" + textBox4.Text + "',PKpResult'" + textBox5.Text + "',PKpscore'" + textBox6.Text + "',PKpPeople'" + textBox7.Text + "',PKpData'" + textBox8.Text + "'where PID='" + id + "'";
            operate.OperateData(strUpdateSql);
            MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
